package com.auth.server.ctrl;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 测试
 *
 * @Author yin_q
 * @Date 2019/8/23 10:06
 * @Email yin_qingqin@163.com
 **/
@RestController
public class TestCtrl {

    @Autowired
    RestTemplate restTemplate;

    @RequestMapping(value = "/hi")
    @HystrixCommand(fallbackMethod = "hiError")
    public String hi(@RequestParam String name){
        System.out.println(name);
        return restTemplate.getForObject("http://MAIL-CLIENT/he/a?name="+name, String.class);
    }

    public String hiError(String name){
        return "hi," + name + " 连接失败";
    }

}
